cmake_minimum_required(VERSION 3.12.4)

# set(TARGET lv_img_conv)

project(${TARGET})

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -fexec-charset=UTF-8 -finput-charset=UTF-8")
aux_source_directory(. SRCS)

include_directories(. include libjpeg/include libpng/include libzip/include)

add_subdirectory(source)

add_executable(${TARGET} ${SRCS})

target_link_directories(
    ${TARGET} PUBLIC
    libjpeg/lib
    libpng/lib
    libzip/lib
)

target_link_libraries(
    ${TARGET}
    -Wl,--start-group
    source
    pthread
    jpeg
    turbojpeg
    png16
    zlib
    -Wl,--end-group
)

install(TARGETS ${TARGET} DESTINATION bin)

add_custom_command(
        TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/libjpeg/lib ${CMAKE_BINARY_DIR}
        )

add_custom_command(
            TARGET ${PROJECT_NAME}  POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy_directory
            ${CMAKE_SOURCE_DIR}/libpng/lib ${CMAKE_BINARY_DIR}
            )

add_custom_command(
        TARGET ${PROJECT_NAME}  POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/libzip/lib ${CMAKE_BINARY_DIR}
        )
